package com.yu.common.constant;

import java.io.File;
import java.util.Locale;

public class Constant {

    // 用户Id默认值，在不能取到登录用户信息时，使用此值做created_by、updated_by的默认值
    public static final String USER_ID_DEFAULT = "SYSTEM";
    // 部门Id默认值，在不能取到登录用户信息时，使用此值做dept_id的默认值
    public static final String DEPT_ID_DEFAULT = "SYSTEM";

    //是否不限制数据权限（全部数据）
    public static final String USER_DATA_PERM_POLICY_ALL = "x-user-data-perm-policy-all";

    // 是否为超级管理员, true / false
    public static final String USER_IS_SUPER_ROLE = "x-user-is-super-role";
    // 用户角色, 多个角色使用","分隔, 例: IE95cP3X2TrUKen8TUuJzl4falhLiSo5Bf9i,Zb6XGns0Ra2SCxtsmI2vk5AO2eyrcsoovT1D
    public static final String USER_ROLES = "x-user-roles";
    // 登录用户部门Id
    public static final String USER_DEPT_ID = "x-user-dept";
    // 用户菜单权限, 多个权限使用","分隔, 例: user.list,user.edit,user.delete
    public static final String USER_MENU_PERMISSIONS = "x-user-permissions";
    // 角色数据权限
    public static final String USER_DATA_PERMISSIONS = "x-user-data-perm-policies";
    // 角色自定义数据权限(指定部门)
    public static final String USER_DATA_CUSTOM_PERMISSIONS_DEPT = "x-user-data-perm-policy-dept";
    //  角色自定义数据权限(指定用户)
    public static final String USER_DATA_CUSTOM_PERMISSIONS_USER = "x-user-data-perm-policy-user";

    // 用户ID
    public static final String USER_ID = "x-user-id";
    // 用户名
    public static final String X_USER_NICKNAME = "x-user-nickname";
    // 用户真实名
    public static final String X_USER_REALNAME = "x-user-realname";

    /**
     * 资产类型 数据对象
     */
    public static final String ASSET_TYPE_DO = "data_object";
    /**
     * 资产类型 非结构
     */
    public static final String ASSET_TYPE_UNSTRUCTURED = "unstructured";

    /**
     * 数据来源  新建
     */
    public static final String DATA_SOURCE_NEW = "new";
    /**
     * 数据来源  数据融合
     */
    public static final String DATA_SOURCE_ETL = "etl";


    public static final String AUDIT_STATE_DEFAULT = "default";
    public static final String AUDIT_STATE_AUDITING = "auditing";
    public static final String AUDIT_STATE_APPROVE = "approve";
    public static final String AUDIT_STATE_REJECT = "reject";


    public static final int FEATURE_TYPE_BATCH = 1;


    /**
     * 数据对象tag
     */
    public static final String FILE_TAG = "File";

    public static final String FILE_ARRAY_TAG = "File[]";
    public static final String DATA_SOURCE_HOST = "host";
    public static final String DATA_SOURCE_PORT = "port";
    public static final String DATA_SOURCE_DATABASE = "database";
    public static final String DATA_SOURCE_USER = "username";
    public static final String DATA_SOURCE_PASSWORD = "password";
    public static final String SYNCTASK_FAILED = "1";
    public static final String SYNCTASK_RUNNING = "2";
    public static final String SYNCTASK_STOPED = "3";
    public static final String DATA_EXCHANGE = "exchange";
    public static final String ASSET_SUBSCRIBE = "subscription";
    public static final String ASSET_DISABLE = "disable";
    public static final String ASSET_ENABLE = "enable";
    public static final String ASSET_STATUS_APPROVE = "approve";
    public static final String ASSET_STATUS_REJECT = "reject";
    public static final String ASSET_STATUS_AUDITING = "auditing";
    public static final String ASSET_STATUS_DEFAULT = "default";
    public static final String UPDATE = "update";
    public static final String CREATE = "create";
    public static final String OPENLOOKENG = "openLooKeng";
    public static final String DATASOURCE = "data_source";
    public static final String DATAVIEW = "data_view";
    public static final String DATAOBJECT = "data_object";
    public static final String DATAMODEL = "data_model";
    public static final String IOTTHINGSERVICE = "iot_thing_service";
    public static final String DC_CANVAS_PROCESSORS_KEY = "dc_canvas_processors";
    //产品授权
    public static final String PRODUCT_AUTHORIZE_SEPARATOR = "/";
    public static final String PRODUCT_AUTHORIZE_REGISTER_FILE = ".register";
    //数据清洗存储桶
    public static final String DC_TASK_OSS_BUCKET = "dctask";
    public static final String PREVIEW_SUFFIX = ".preview";
    public static final String CSV_SUFFIX = ".csv";
    public static final String EXCEL_SUFFIX = ".xlsx";
    public static final int PREVIEW_COUNT = 5000;
    public static final String TMP_PATH = System.getProperty("java.io.tmpdir") + File.separator;
    public static final String DATA_MODEL_ATTR_TYPE_STATIC = "static";
    public static final String HBASE_DEFAULT_COLUMNFAMILY = "f1";
    //kerberos密钥文件在MINIO上都是固定名称的
    public static final String AUTHFILE_JAAS = "jaasFile";
    public static final String AUTHFILE_HBASESITE = "hbaseSiteFile";
    public static final String AUTHFILE_KRB5CONF = "krb5ConfFile";
    public static final String AUTHFILE_KEYTAB = "keytabFile";
    public static final String AUTHFILE_BUCKET = "datasource";
    public static final String AUTHFILE_TMP_PATH = "/tmp/";
    /**
     * 数据清洗最大预览数据量
     */
    //TODO 与产品沟通返回50条，
    public static int MAX_DC_PREVIEW = 50;

    public static enum DATA_OBJECT_TYPE {
        data_object,
        file,
        directory;

    }


    public enum DC_STATUS {
        PUBLISHED,  //已发布
        OFFLINE;//待发布

        public static boolean isVaild(String value) {
            DC_STATUS[] status = DC_STATUS.values();
            for (DC_STATUS dc_status : status) {
                if (dc_status.value().equals(value)) {
                    return true;
                }
            }
            return false;
        }

        public String value() {
            return this.name().toLowerCase(Locale.ROOT);
        }
    }

    /**
     * 流程组状态
     */
    public enum ProcessStatusState {
        RUNNING,
        STOPPED;
    }


    public enum StandardStatus {
        /**
         * 待发布
         */
        offline,
        /**
         * 已发布
         */
        published,
        /**
         * 已作废
         */
        invalid;

    }

    /**
     * 数据源状态
     */
    public static enum APPLY_STATUS {
        // 申请通过
        APPROVE,
        // 审核中
        AUDITING,
        REJECT,
        // 默认
        DEFAULT;

        public String value() {
            return this.name().toLowerCase(Locale.ROOT);
        }
    }


    public static enum CATEGORY_POSITION {
        BEFORE,
        AFTER,
        INNER;

        public String value() {
            return this.name().toLowerCase(Locale.ROOT);
        }
    }

    /**
     * 数据视图sql解析状态
     */
    public static enum DataViewSqlParseStatus {
        // 默认值
        DEFAULT,
        //成功
        SUCCESS,
        //失败
        ERROR;

        public String value() {
            return this.name().toLowerCase(Locale.ROOT);
        }
    }

    /**
     * 数据视图发布状态
     */
    public static enum DataViewPublishedStatus {
        PUBLISHED, //发布
        UNPUBLISHED;//未发布

        public String value() {
            return this.name().toLowerCase(Locale.ROOT);
        }
    }

    public static class NIFI {
        //目标processor 名称，需要与模板保持一致，约定好
        public static final String SINK_PROCESSOR_NAME = "sink";
    }

    public static class DateTimeFormat {
        public static final String DATE_FORMAT = "YYYY-MM-DD";
        public static final String TIME_FORMAT = "YYYY-MM-DD HH:MM:SS";

    }

    public static class NifiCacheKey {

        //  value  为对应       generateflowfile  processor ID
        public static final String PROCESS_GROUP_GENERATE_FLOW_KEY = "nifi:processgroup:generateflowfile:";
        //流程组对应 源 processorId
        public static final String PROCESS_GROUP_SOURCE_KEY = "nifi:processgroup:source:";
        //流程组对应 目标 processorId
        public static final String PROCESS_GROUP_SINK_KEY = "nifi:processgroup:sink:";
        // value为 [{"type":"GenerateTableFetch","processorId":"9309920b-5f40-303c-80d0-474fc30cc738"}]
        public static final String PROCESS_GROUP_PROCESSORS_KEY = "nifi:processgroup:processors:";
        // nifi 控制器id
        public static final String NIFI_CONTROLLER_SERVICE_KEY = "nifi:controllerservice:";

        public static final String NIFI_TEMPLATE_SYNCTASK_KEY = "nifi:template:synctask";

        public static final String NIFI_TEMPLATE_IOTDBSYNC_KEY = "nifi:template:iotdbsync";

    }

    public static class DataObjectAttrType {
        public static final String NONSTATIC = "non-static";
        public static final String STATIC = "static";
    }

    public static class DataObjectAttrTypeStr {
        public static final String NONSTATIC_STR = "非静态属性";
        public static final String STATIC_STR = "静态属性";
    }

    public static class BooleanStr {
        public static final String TRUE_STR = "true";
        public static final String FALSE_STR = "false";
        public static final String TRUE = "是";
        public static final String FALSE = "否";
    }

    public static class DataObjectDataType {
        public static final String DATETIME = "DATETIME";
        public static final String BOOLEAN = "BOOLEAN";
        public static final String VARCHAR = "VARCHAR";
        public static final String INTEGER = "INT";
        public static final String DATE = "DATE";
        public static final String DOUBLE = "FLOAT";
        public static final String ENUM = "ENUM";
        public static final String IMAGE = "IMAGE";
        public static final String FILE = "FILE";
    }

    public static class DataObjectDataTypeStr {
        public static final String DATETIME_STR = "日期时间型";
        public static final String DATE_STR = "日期型";
        public static final String BOOLEAN_STR = "布尔型";
        public static final String VARCHAR_STR = "字符型";
        public static final String INTEGER_STR = "整数型";
        public static final String DOUBLE_STR = "小数型";
        public static final String ENUMERATION_STR = "枚举型";
        public static final String IMAGE_STR = "图片型";
        public static final String FILE_STR = "文件型";
    }

    public static class ColumnSeparator {
        public static final String COMMA = "comma";
        public static final String SEMICOLON = "semicolon";
        public static final String COLON = "colon";
        public static final String TAB = "tab";
    }

    public static class TextQualifier {
        public static final String DOUBLEQUOTATION = "doubleQuotation";
        public static final String SINGLEQUOTATION = "singleQuotation";
        public static final String NEWLINECHARACTER = "newlineCharacter";
    }

    public static class OperatingSystem {
        public static final String DOS = "DOS";
        public static final String UNIX = "UNIX";
        public static final String MAC = "MAC";
        public static final String MIXED = "MIXED";
    }

    public static class DataObjectType {
        public static final String DATAOBJECT = "data_object";
    }

    public static class DataObjectSourceType {
        public static final String ORININALTABLE = "original_table";
        public static final String NEWTABLE = "new_table";
        public static final String VIEW = "view";
    }
}
